package com.ctgu.admin.system.repository;

import com.ctgu.admin.system.domain.Information;
import com.ctgu.modules.system.repository.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 站内消息的持久层
 */
public interface InformationRepository extends BaseRepository<Information, Long> {

    @Query(value = "select * from sys_information where userID = ?1 and status = 0",nativeQuery = true)
    public List<Information> selectInformationByUserId(Long userID);

    @Transactional
    @Query("update Information set status = 1 where id = ?1")
    @Modifying
    public int readInformationById(Long id);
}